<template>
    <div id="root">
        <button @click="getStudents()">获取学生信息</button>
        <button @click="getCars()">获取汽车信息</button>
    </div>
</template>

<script>
    // 终端执行安装 axios :npm install axios --save
    // 引入 axios 
    import axios from 'axios'

    export default {
        name:'App',
        data(){
            return{
                
            }
        },
        methods:{
            getStudents(){
                axios.get('http://127.0.0.1:8080/atbian/students').then(
                    response =>{
                        console.log('请求成功',response.data);
                    },
                    error=>{
                        console.log('请求失败',error.message);
                    }
                )
            },
            getCars(){
                axios.get('http://127.0.0.1:8080/demo/cars').then(
                    response =>{
                        console.log('请求成功',response.data);
                    },
                    error=>{
                        console.log('请求失败',error.message);
                    }
                )
            }
        }
    }
</script> 

<style>
     
</style>

 